package com.tianqingwl.gsystem.resources.controller;

import com.tianqingwl.gsystem.sysuser.pojo.SysUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 掌管所有资源索引
 */
@Controller
public class ManageIndexController {

    @RequestMapping({"/manage/","/manage/index.html"})
    public String manageIndex(Model model){
        SysUser sysUser = (SysUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        model.addAttribute("currentUser",sysUser);
        return "manage/index";
    }

    @GetMapping("/login.html")
    public String toLoginPage(){
        return "manage/login";
    }

    @RequestMapping({"/manage/permission/index.html"})
    @PreAuthorize("@gs.check('sys_manage_permission')")
    public String permissionIndex(){
        return "manage/permission/index";
    }


}
